package com.example.mobile2021606145zbq0407homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.mobile2021606145zbq0407homework.R;

public class MainActivity3 extends AppCompatActivity {

    private TextView tvMainTitle2;
    private TextView tvMain22;
    private TextView tvMain23;
    private TextView twoIntOne;
    private EditText edtTwoOne;
    private TextView twoIntTwo;
    private EditText edtTwoTwo;
    private TextView twoIntThree;
    private EditText edtTwoThree;
    private Button btn2;
    private TextView TVResult2;
    int max = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        initView();
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = edtTwoOne.getText().toString();
                String string1 = edtTwoTwo.getText().toString();
                String string2 = edtTwoThree.getText().toString();
                int num1=Integer.valueOf(string).intValue();
                int num2=Integer.valueOf(string1).intValue();
                int num3=Integer.valueOf(string2).intValue();
                if (num1 > num2 ){
                    max = num1;
                }else {
                    max = num2;
                }
                if (num2 > num3){
                    max = num2;
                }else {
                    max = num3;
                }
                if (num1 > num3){
                    max = num1;
                }else {
                    max = num3;
                }
                string=String.valueOf(max);
                TVResult2.setText(string);
            }
        });
    }

    private void initView() {
        tvMainTitle2 = (TextView) findViewById(R.id.tv_main_title2);
        tvMain22 = (TextView) findViewById(R.id.tv_main_2_2);
        tvMain23 = (TextView) findViewById(R.id.tv_main_2_3);
        twoIntOne = (TextView) findViewById(R.id.two_int_one);
        edtTwoOne = (EditText) findViewById(R.id.edt_two_one);
        twoIntTwo = (TextView) findViewById(R.id.two_int_two);
        edtTwoTwo = (EditText) findViewById(R.id.edt_two_two);
        twoIntThree = (TextView) findViewById(R.id.two_int_three);
        edtTwoThree = (EditText) findViewById(R.id.edt_two_three);
        btn2 = (Button) findViewById(R.id.btn_2);
        TVResult2 = (TextView) findViewById(R.id.TV_result_2);
    }
}